<?php
namespace App\Services;
use OSS\OssClient;
class OssServices{

 public function __construct(){
 	    //阿里云oss文件存储器的key值
        $this->accessKeyId= "LTAI5tRWsaqtdk7H9wYbT8p8";
        //阿里云oss文件存储器的Secret密匙
        $this->accessKeySecret= "nWyTQhGThOFEk4kb2wQlbCcIUEInRK";
        //阿里云oss文件存储器存储空间名称。
        $this->bucket= "jintwooss";
        //阿里云oss文件存储器存网址。
        $this->endpoint= "https://oss-cn-hangzhou-internal.aliyuncs.com";


    }
public function upload($object,$filePath){
  $ossClient = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint);
    try{
       $result=$ossClient->uploadFile($this->bucket,$object,$filePath);
       $url=$result['info']['url'];
       return  substr_replace($url, "", strpos($url,'-internal'), strlen('-internal'));
    } catch(\Exception $e) {
         return $e->getMessage();
       }
}




}
